#拼多多评价启动项目

from helper import Helper
from comments import PddComments
from urllib.parse import unquote
import json,sys




class StartUp( object ):

    def __init__(self):

        pass

    def startRequest(self,task):

        # 获取cookie
        cookie = unquote(task['cookie'])
        task['cookie'] = cookie
        # 正常请求
        if Helper.testCaseReqeust( task ):

            c = PddComments()

            c.requestIndex( task )

        else:
            # shop_id task_id state = 6
            #被封号状态 返回服务器
            data = json.dumps({
                        "caijiwancheng": [{
                        "task_id": task['id'],
                        "state": "6",
                        "shop_id": task['shop_id']
                    }]
                })

            Helper.returnCommentTask( data )
            print('官方账号被封禁,进行退出操作,回执任务ID:',task['id'])
            # os.system('pause')
            sys.exit()




if __name__ == '__main__':

    s = StartUp()

    task = {'id': '602261', 'shop_id': '140', 'content': None, 'state': '0', 'type': '8', 'all_num': '0', 'excu_num': '0', 'doletime': '2019-09-16 17:59:00', 'addby': '31', 'createtime': '2019-09-15 10:46:13', 'editby': '999', 'edittime': '2019-09-16 17:59:01', 'is_super': '0', 'supertime': None, 'del': '0', 't_id': None, 't_start_time': '2019-08-27 11:30:00', 't_end_time': '2019-08-27 11:45:00', 't_exe_start_time': '2019-08-27 11:30:00', 't_exe_end_time': '2019-08-27 11:45:00', 'insert_type': '2', 'details_type': None, 'question_state': '0', 'num_error': '0', 'dls': None, 'is_pic': None, '48udpdate': None, 'cookie': 'api_uid%3DrBQR6l2ArlyhxCxaYf4%2BAg%3D%3D%3B_nano_fp%3DXpdjl0man0XqXpTbX9_kgUfZ_WuXtP5PviZl42EQ%3BPASS_ID%3D1-ySvxYLo8Lyba1Yt5hzmqk01s55zIbCHv7DFWzsd8zo3iPsusA3SNzSHJJxKAzADh%2F%2BA7BxWs%2F9rjxSPzhHKtoA_743867898_44048600', 'account': '浪莎护肤旗舰店dsr', 'shop_name': '浪莎护肤旗舰店'}

    s.startRequest( task )

